﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddDishes.aspx.cs" Inherits="BuXiaChu.OrderDishes.Web.Admin.Restaurant.AddDishes" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register TagPrefix="Menu" TagName="Header" Src="~/Modules/Menu/Header.ascx" %>
<%@ Register TagPrefix="Menu" TagName="Footer" Src="~/Modules/Menu/Footer.ascx" %>
<%@ Register TagPrefix="Menu" TagName="CityLeft" Src="~/Modules/Menu/CityLeft.ascx" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/Blueprint/screen.css" />
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/main.css" />

    <script type="text/javascript" src="../js/Extend.js"></script>

    <script type="text/javascript" src="../js/Common.js"></script>

    <script type="text/javascript" src="../js/jquery-vsdoc.js"></script>

</head>
<body>
    <div class="container">
        <Menu:Header ID="Header1" runat="server" />
        <form id="form1" runat="server">
        <Menu:CityLeft ID="menu_CityLeft" runat="server" />
        <div class="span-20 last">
            <div class="boxc">
                <a href="Dishes.aspx?restaurantId=<%=Request.QueryString["restaurantId"] %>&&restaurantName=<%= Request.QueryString["restaurantName"] %>">
                    菜品管理</a> <span>|</span> <a href="AddDishesCat.aspx?restaurantId=<%= Request.QueryString["restaurantId"] %>&restaurantName=<%= Request.QueryString["restaurantName"] %>">
                        菜品类别管理</a>
            </div>
            <div class="editor">
                <div class="label">
                    菜品名称
                </div>
                <div class="field">
                    <input type="text" id="txt_Name" runat="server" />
                </div>
                <div class="label">
                    菜品类别
                </div>
                <div class="field">
                    <select runat="server" id="sel_Cat">
                    </select>
                </div>
                <div class="label">
                    单价
                </div>
                <div class="field">
                    <input type="text" id="txt_Price" runat="server" />元<span id="txt_Price_tips_"></span>
                </div>
                <div class="label">
                    单位
                </div>
                <div class="field">
                    <select runat="server" id="sel_Unit">
                    </select>
                </div>
                <div class="label">
                    折扣比
                </div>
                <div class="field">
                    <input type="text" id="txt_Discount" runat="server" />%<span id="txt_Discount_tips_"></span>
                </div>
                <div class="label">
                    发票折扣比
                </div>
                <div class="field">
                    <input type="text" id="txt_InvoiceDiscount" runat="server" />%<span id="txt_InvoiceDiscount_tips_"></span>
                </div>
                <div class="label">
                    包装盒数量
                </div>
                <div class="field">
                    <input type="text" id="txt_Box" runat="server" />
                </div>
                <div class="label">
                    包装盒单价
                </div>
                <div class="field">
                    <input type="text" id="txt_BoxUnitPrice" runat="server" />元<span id="txt_BoxUnitPrice_tips_"></span>
                </div>
                <div class="label">
                    图片
                </div>
                <div class="field">
                    <input type="file" style="height: 25px" onchange="previewImage(this)" runat="server"
                        id="txt_Image" />
                    <img id="img_PreviewImage" runat="server" style="display: none; width: 80px; height: 90px;" />
                    <div id="div_PreviewImageOther" style="display: none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale);
                        text-align: center;">
                    </div>
                </div>
                <div class="label">
                    描述
                </div>
                <div class="field">
                    <textarea id="txt_Description" style="width: 300px; height: 80px;" runat="server"></textarea>
                </div>
                <div class="label">
                    内部注释
                </div>
                <div class="field">
                    <textarea id="txt_InternalRemarks" style="width: 300px; height: 80px;" runat="server"></textarea>
                </div>
                <div class="label">
                </div>
                <div class="field">
                    <input type="submit" id="btn_Save" value="保存" />
                </div>
            </div>
        </div>
        </form>
        <Menu:Footer ID="Footer1" runat="server" />
    </div>
</body>
</html>

<script type="text/javascript" src="../js/FormValid.js"></script>

<script type="text/javascript">
    function previewImage(obj) {
        var imgSrc = "";
        if (obj.files) {
            imgSrc = obj.value;
        } else {
            obj.select();
            imgSrc = document.selection.createRange().text;
        }

        var fileType = imgSrc.substring(imgSrc.lastIndexOf(".") + 1);
        if (fileType != "jpeg" && fileType != "bmp" && fileType != "jpg") {
            alert("图片格式只支持.jpeg .bmp .jpg")
            return;
        }

        if (obj.files) {
            var preImg = jDoc('img_PreviewImage');
            preImg.src = obj.files[0].getAsDataURL();
            preImg.style.display = "block";
        } else if (jDoc("div_PreviewImageOther").filters) {
            var otherShow = jDoc("div_PreviewImageOther");
            otherShow.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
            otherShow.style.width = "90px";
            otherShow.style.height = "80px";
            otherShow.style.display = "block";
            jDoc('img_PreviewImage').style.display = "none";
        }
    }

    ElementValidator.className.error = "error";
    ElementValidator.className.correct = "success";
    ElementValidator.className.def = "notice";
    ElementValidator.className.focus = "notice";
    var formValidator = new ElementValidator();
    formValidator.addText({ id: "txt_Name", focus: "请输入菜品名称", defTips: "菜品名称必填", len: { text: /^.{2,20}$/, errorMsg: "菜品名称需要2-20个字" }, tips: { correctMsg: "OK"} });
    formValidator.addText({ id: "txt_Price", focus: "请输入菜品价格", defTips: "菜品价格必填", len: { text: /^[0-9]+(.[0-9]{1,3})?$/, errorMsg: "菜品价格输入错误" }, tips: { correctMsg: "OK"} });
    formValidator.addText({ id: "txt_Discount", focus: "请输入折扣比", defTips: "折扣比必填", len: { text: /^\d{2}$/, errorMsg: "折扣比输入错误10-99" }, tips: { correctMsg: "OK"} });
    formValidator.addText({ id: "txt_InvoiceDiscount", focus: "请输入发票折扣比", defTips: "发票折扣比必填", len: { text: /^\d{2}$/, errorMsg: "发票折扣比输入错误10-99"} });
    formValidator.addText({ id: "txt_Box", focus: "请填写数字", reg: { text: /^\d+$/, errorMsg: "输入错误，请输入数字"} });
    formValidator.addText({ id: "txt_BoxUnitPrice", focus: "请填写数字 可以有小数", reg: { text: /^[0-9]+(.[0-9]{1,3})?$/, errorMsg: "输入错误,请填写数字 可以有小数" }, tips: { correctMsg: "OK"} });
    $(jDoc("btn_Save")).bind("click", function() {
        return formValidator.validate();
    })
    
</script>

<script type="text/javascript">
    if ('<%=message %>' == 1) {
        alert("操作成功");
    } else if ('<%=message %>' == 0) {
        alert("操作失败");
    }
    if (jDoc("img_PreviewImage").src != "") {
        jDoc("img_PreviewImage").style.display = "block";
    }
</script>

